<template>
	<view class="content">
		<view class="info-block" @click="goDetail(data)">
			<image :src="data.coverImage" class="icon" mode="aspectFill"></image>
			<view class="info-item">
				<view class="name-item">
					<view class="name">{{data.title}}</view>
					<view class="price" v-if="data.price">￥{{data.price}}</view>
				</view>
				<view class="describe" v-if="data.describe">{{data.describe}}</view>
				<view class="describe" v-if="!data.describe">{{data.account}}</view>
				<view class="address-item" v-if="data.address">
					<view class="address-left">
						<image class="iconfont" src="@/static/images/position.png"></image>
						<view class="address">{{data.address}}</view>
					</view>
					<!-- 	<view class="distance">{{data.distance}}km</view> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "ListItem",
		props: {
			data: Object,
			type: Number
		},
		data() {
			return {};
		},
		methods: {
			goDetail(e) {
				if (this.type == 1) {
					uni.navigateTo({
						url: '/page_pack/products/details?id=' + e.id
					})
				} else {
					uni.navigateTo({
						url: '/page_pack/products/detail1?id=' + e.id
					})
					setTimeout(() => {
						uni.$emit('seedDetail', e)
					}, 500)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		margin-top: 30rpx;

		.info-block {
			display: flex;
			align-items: center;
			background-color: #fff;
			margin-bottom: 30rpx;
			padding: 30rpx;
			border-radius: 30rpx;

			.icon {
				width: 160rpx;
				height: 160rpx;
				margin-right: 20rpx;
				border-radius: 20rpx;
			}

			.info-item {
				height: 100%;
				width: calc(100% - 180rpx);
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.name-item {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.name {
						font-weight: bold;
						font-size: 30rpx;
					}

					.price {
						font-size: 30rpx;
						color: #64B548;
						font-weight: bold;
					}
				}

				.describe {
					color: #767676;
					font-size: 28rpx;
					margin-top: 30rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.address-item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 30rpx;
					color: #767676;
					font-size: 28rpx;

					.address-left {
						display: flex;
						align-items: center;

						.iconfont {
							width: 35rpx;
							height: 35rpx;
							margin-right: 10rpx;
						}
					}
				}
			}
		}
	}
</style>